<%@page import="Post.PostVo"%>
<%@page import="Post.PostDao"%>
<%@page import="Post.PostVo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Post.PostDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>주소찾기</title>
<script>
	function num(zipcode, si, gu, dong, bunji) {
		var doc = window.opener;//나를 연 윈도우   (메인)
	
		//메인 윈도우의 입력상자들	
		var receiveMsg1 = doc.document.getElementById("addr1");
		var receiveMsg2 = doc.document.getElementById("addr2");

		//현재창 입력상자	
	
		var r = document.getElementById('zip');
		var r1 = document.getElementById('zip1');
		
		receiveMsg1.value = zipcode;
		receiveMsg2.value = si + gu + dong + bunji;
		window.close();
	}
</script>
<style>
#tot {
	border: 1px solid #aaaaaa;
	width: 500px;
}

#main {
	width: 500px;
}

#dn {
	display: inline-block;
	width: 120px;
}

#wn {
	display: inline-block;
	width: 300px;
}

.imain {
	width: 500px;
}

.ok {
	display: inline-block;
	width: 50px;
}
</style>
</head>
<body>


	<%
		request.setCharacterEncoding("utf-8");
		String search=request.getParameter("addr");
		PostDao dao=new PostDao();
		ArrayList<PostVo> list=dao.getAddrs(search);
	%>


	<form action='postsearch.jsp'>
		주소검색:<input type='text' name='addr'><input type='submit'
			value='검색'> 예)압구정동
		<div id='tot'>
			<div id='main'>
				<div id='dn'>우편번호</div>
				<div id='wn'>주소</div>
			</div>
			<%
				System.out.println(list.size());
				for(int i=0; i<list.size();i++){
				PostVo p = list.get(i);
			%>

			<div class='imain'>
				<input type='text' id='zip' size='10px' disabled
					value='<%=p.getZipcode()%>'
					onclick="click('<%=p.getZipcode()%>', '<%=p.getSido()%>', '<%=p.getGugun()%>', '<%=p.getDong()%>','<%=p.getBunji()%>')">

				<input type='text' id='zip1' size='50px' disabled
					value='<%=p.getSido()%><%=p.getGugun()%><%=p.getDong()%><%=p.getBunji()%>'
					onclick="click('<%=p.getZipcode()%>', '<%=p.getSido()%>', '<%=p.getGugun()%>', '<%=p.getDong()%>','<%=p.getBunji()%>')">

				<div class='ok'>
					<input type='button' value='선택'
						onclick="num('<%=p.getZipcode()%>', '<%=p.getSido()%>', '<%=p.getGugun()%>', '<%=p.getDong()%>','<%=p.getBunji()%>')">
				</div>
			</div>

			<%}%>
		</div>
	</form>



</body>
</html>